import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'

// vite按需导入Element样式
// import AutoImport from 'unplugin-auto-import/vite'
// import Components from 'unplugin-vue-components/vite'
// import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    // 允许IP访问
    host: '0.0.0.0',
    port: 5174
  },
  plugins: [
    vue(),
    vueJsx(),
    vueDevTools()
    // 按需导入
    // AutoImport({
    //   resolvers: [ElementPlusResolver()],
    // }),
    // Components({
    //   resolvers: [ElementPlusResolver({ importStyle: "sass" })],
    // }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
  // css: {
  //   preprocessorOptions: {
  //     scss: {
  //       // 使用vite加载scss文件
  //       additionalData: `@use "@/styles/element/index.scss" as *;`,
  //       api: 'modern-compiler'
  //     },
  //   },
  // }
})
